using System;
using Reign.Core;
using WaterDemo;

namespace WaterDemo_iOS
{
	public class MainApplication : Application
	{
		Game game;
		bool loaded;
	
		public MainApplication ()
		: base(ApplicationTypes.OpenGL, ApplicationOrientations.Landscape)
		{
			
		}
		
		protected override void shown ()
		{
			base.shown ();
			try
			{
				game = new Game(this);
				loaded = true;
			}
			catch (Exception e)
			{
				Message.Show("Error", e.Message);
				Console.WriteLine(e.Message);
				Close();
			}
		}
		
		protected override void closing ()
		{
			Console.WriteLine("Closing");
			loaded = false;
			if (game != null)
			{
				game.Dispose();
				game = null;
			}
			base.closing ();
		}

		protected override void updateScene ()
		{
			if (!loaded) return;
			game.Update();
			game.Render();
		}
	}
}

